#include "choosehero.h"
#include<QIcon>
#include<QtDebug>
ChooseHero::ChooseHero(QWidget *parent) : QMainWindow(parent)
{
    //设置窗口固定尺寸
    setFixedSize(600,800);
    //设置标题
    setWindowTitle(GAME_TITLE);
    //设置标题图片
    setWindowIcon(QIcon(":/rec.image/Icon.png"));
    //设置导向

    //战机一
    Hero_Btn1=new QPushButton;
    Hero_Btn1->setParent(this);
    Hero_Btn1->setIcon(QIcon(HERO_PATH1));
    Hero_Btn1->setIconSize(QSize(400,400));
    Hero_Btn1->setFixedSize(200,200);
    Hero_Btn1->move(0,150);
    Hero_Btn1->setFlat(true);
    Hero_Btn1->setAttribute(Qt::WA_TranslucentBackground);

    //选择战机一
    connect(Hero_Btn1,&QPushButton::clicked,[=](){
         btn_music->play();
        //弹出对话框
        QMessageBox msgBox;
        //对话框主题
        msgBox.setInformativeText("   是否出战？  ");
       // 对话框选项
        msgBox.setStandardButtons(QMessageBox::Yes |  QMessageBox::Cancel);
        //msgBox.setDefaultButton(QMessageBox::Save);
        //对话框图片
        QPixmap pix;
        pix.load(":/rec.image/Myplane01.png");
        msgBox.setIconPixmap(pix);
        msgBox.setWindowTitle("选择战机");
        msgBox.setWindowIcon(QIcon(":/rec.image/Icon.png"));

        int ret = msgBox.exec();
        switch (ret) {
        case QMessageBox::Yes:
            emit(SelectHero1());
            break;

          }

    });
    //战机二
    Hero_Btn2=new QPushButton;
    Hero_Btn2->setParent(this);
    Hero_Btn2->setIcon(QIcon(":/rec.image/Myplane02_nobuy.png"));
    Hero_Btn2->setIconSize(QSize(400,400));
    Hero_Btn2->setFixedSize(200,200);
    Hero_Btn2->move(200,150);
    Hero_Btn2->setFlat(true);
    Hero_Btn2->setAttribute(Qt::WA_TranslucentBackground);
    //选择战机二
    connect(Hero_Btn2,&QPushButton::clicked,[=](){
         btn_music->play();
        if(Hero2_isbuy)
        {
            QMessageBox msgBox;
            msgBox.setInformativeText("   是否出战？  ");
            msgBox.setStandardButtons(QMessageBox::Yes |  QMessageBox::Cancel);
            //msgBox.setDefaultButton(QMessageBox::Save);
            QPixmap pix;
            pix.load(":/rec.image/Myplane02.png");
            msgBox.setIconPixmap(pix);
            msgBox.setWindowTitle("选择战机");
            msgBox.setWindowIcon(QIcon(":/rec.image/Icon.png"));
            int ret = msgBox.exec();
            switch (ret) {
            case QMessageBox::Yes:
                emit(SelectHero2());
                break;

            }
        }
        else
        {
            QMessageBox::warning(this,"warn","未拥有该战机");
        }
    });
    //战机三
    Hero_Btn3=new QPushButton;
    Hero_Btn3->setParent(this);   
    Hero_Btn3->setIcon(QIcon(":/rec.image/Myplane03_nobuy.png"));
    Hero_Btn3->setIconSize(QSize(400,400));
    Hero_Btn3->setFixedSize(200,200);
    Hero_Btn3->move(400,150);
    Hero_Btn3->setFlat(true);
    Hero_Btn3->setAttribute(Qt::WA_TranslucentBackground);

    //选择战机三
    connect(Hero_Btn3,&QPushButton::clicked,[=](){
         btn_music->play();
        if(Hero3_isbuy)
        {
            QMessageBox msgBox;
            msgBox.setInformativeText("   是否出战？  ");
            msgBox.setStandardButtons(QMessageBox::Yes |  QMessageBox::Cancel);
            //msgBox.setDefaultButton(QMessageBox::Save);
            QPixmap pix;
            pix.load(HERO_PATH3);
            msgBox.setIconPixmap(pix);
            msgBox.setWindowTitle("选择战机");
            msgBox.setWindowIcon(QIcon(":/rec.image/Icon.png"));
            int ret = msgBox.exec();
            switch (ret) {
            case QMessageBox::Yes:
                emit(SelectHero3());
                break;

            }
        }
        else
        {
            QMessageBox::warning(this,"warn","未拥有该战机");
        }

    });
    //返回
    return1=new QPushButton;
    return1->setParent(this);
    return1->setIcon(QIcon(":/rec.image/return.png"));
    return1->setIconSize(QSize(400,400));
    return1->setFixedSize(100,50);
    return1->move(500,750);
    connect(return1,&QPushButton::clicked,[=](){
         btn_music->play();
        emit(returnmainscence());
        qDebug()<<1;

    });



    //僚机一
    Wing_Btn1=new QPushButton;
    Wing_Btn1->setParent(this);    
    Wing_Btn1->setIcon(QIcon(":/rec.image/Wing01_nobuy.png"));
    Wing_Btn1->setIconSize(QSize(200,200));
    Wing_Btn1->setFixedSize(100,100);
    Wing_Btn1->move(50,350);
    Wing_Btn1->setFlat(true);
    Wing_Btn1->setAttribute(Qt::WA_TranslucentBackground);


    //选择僚机一
    connect(Wing_Btn1,&QPushButton::clicked,[=](){
         btn_music->play();
        if(Wing1_isbuy)
        {
            QMessageBox msgBox;
            msgBox.setInformativeText("   是否出战？  ");
            msgBox.setStandardButtons(QMessageBox::Yes |  QMessageBox::Cancel);
            //msgBox.setDefaultButton(QMessageBox::Save);
            QPixmap pix;
            pix.load(":/rec.image/Wing01.png");
            msgBox.setIconPixmap(pix);
            msgBox.setWindowTitle("选择战机");
            msgBox.setWindowIcon(QIcon(":/rec.image/Icon.png"));
            int ret = msgBox.exec();
            switch (ret) {
            case QMessageBox::Yes:
                emit(SelectWing1());
                break;

            }
        }
        else
        {
            QMessageBox::warning(this,"warn","未拥有该战机");
        }
    });

    //僚机2
    Wing_Btn2=new QPushButton;
    Wing_Btn2->setParent(this);   
    Wing_Btn2->setIcon(QIcon(":/rec.image/Wing03_nobuy.png"));
    Wing_Btn2->setIconSize(QSize(800,800));
    Wing_Btn2->setFixedSize(100,100);
    Wing_Btn2->move(250,350);
    Wing_Btn2->setFlat(true);
    Wing_Btn2->setAttribute(Qt::WA_TranslucentBackground);
    //选择僚机2
    connect(Wing_Btn2,&QPushButton::clicked,[=](){
         btn_music->play();
        if(Wing2_isbuy)
        {
            QMessageBox msgBox;
            msgBox.setInformativeText("   是否出战？  ");
            msgBox.setStandardButtons(QMessageBox::Yes |  QMessageBox::Cancel);
            //msgBox.setDefaultButton(QMessageBox::Save);
            QPixmap pix;
            pix.load(":/rec.image/Wing03.png");
            msgBox.setIconPixmap(pix);
            msgBox.setWindowTitle("选择战机");
            msgBox.setWindowIcon(QIcon(":/rec.image/Icon.png"));
            int ret = msgBox.exec();
            switch (ret) {
            case QMessageBox::Yes:
                emit(SelectWing2());
                break;

            }
        }
        else
        {
            QMessageBox::warning(this,"warn","未拥有该战机");
        }
    });

    //僚机3
    Wing_Btn3=new QPushButton;
    Wing_Btn3->setParent(this);
    Wing_Btn3->setIcon(QIcon(":/rec.image/Wing04_nobuy.png"));
    Wing_Btn3->setIconSize(QSize(800,800));
    Wing_Btn3->setFixedSize(100,100);
    Wing_Btn3->move(450,350);
    Wing_Btn3->setFlat(true);
    Wing_Btn3->setAttribute(Qt::WA_TranslucentBackground);
    //选择僚机3
    connect(Wing_Btn3,&QPushButton::clicked,[=](){
         btn_music->play();
        if(Wing3_isbuy)
        {
            QMessageBox msgBox;
            msgBox.setInformativeText("   是否出战？  ");
            msgBox.setStandardButtons(QMessageBox::Yes |  QMessageBox::Cancel);
            //msgBox.setDefaultButton(QMessageBox::Save);
            QPixmap pix;
            pix.load(":/rec.image/Wing04.png");
            msgBox.setIconPixmap(pix);
            msgBox.setWindowTitle("选择战机");
            msgBox.setWindowIcon(QIcon(":/rec.image/Icon.png"));
            int ret = msgBox.exec();
            switch (ret) {
            case QMessageBox::Yes:
                emit(SelectWing3());
                break;

            }
        }
        else
        {
            QMessageBox::warning(this,"warn","未拥有该战机");
        }
    });

    //僚机4
    Wing_Btn4=new QPushButton;
    Wing_Btn4->setParent(this);
    Wing_Btn4->setIcon(QIcon(":/rec.image/Wing05_nobuy.png"));
    Wing_Btn4->setIconSize(QSize(800,800));
    Wing_Btn4->setFixedSize(100,100);
    Wing_Btn4->move(50,500);
    Wing_Btn4->setFlat(true);
    Wing_Btn4->setAttribute(Qt::WA_TranslucentBackground);
    //选择僚机4
    connect(Wing_Btn4,&QPushButton::clicked,[=](){
         btn_music->play();
        if(Wing4_isbuy)
        {
            QMessageBox msgBox;
            msgBox.setInformativeText("   是否出战？  ");
            msgBox.setStandardButtons(QMessageBox::Yes |  QMessageBox::Cancel);
            //msgBox.setDefaultButton(QMessageBox::Save);
            QPixmap pix;
            pix.load(":/rec.image/Wing05.png");
            msgBox.setIconPixmap(pix);
            msgBox.setWindowTitle("选择战机");
            msgBox.setWindowIcon(QIcon(":/rec.image/Icon.png"));
            int ret = msgBox.exec();
            switch (ret) {
            case QMessageBox::Yes:
                emit(SelectWing4());
                break;

            }
        }
        else
        {
            QMessageBox::warning(this,"warn","未拥有该战机");
        }
    });

    //僚机5
    Wing_Btn5=new QPushButton;
    Wing_Btn5->setParent(this);
    Wing_Btn5->setIcon(QIcon(":/rec.image/Wing06_nobuy.png"));
    Wing_Btn5->setIconSize(QSize(800,800));
    Wing_Btn5->setFixedSize(100,100);
    Wing_Btn5->move(250,500);
    Wing_Btn5->setFlat(true);
    Wing_Btn5->setAttribute(Qt::WA_TranslucentBackground);
    //选择僚机5
    connect(Wing_Btn5,&QPushButton::clicked,[=](){
         btn_music->play();
        if(Wing5_isbuy)
        {
            QMessageBox msgBox;
            msgBox.setInformativeText("   是否出战？  ");
            msgBox.setStandardButtons(QMessageBox::Yes |  QMessageBox::Cancel);
            //msgBox.setDefaultButton(QMessageBox::Save);
            QPixmap pix;
            pix.load(":/rec.image/Wing06.png");
            msgBox.setIconPixmap(pix);
            msgBox.setWindowTitle("选择战机");
            msgBox.setWindowIcon(QIcon(":/rec.image/Icon.png"));
            int ret = msgBox.exec();
            switch (ret) {
            case QMessageBox::Yes:
                emit(SelectWing5());
                break;

            }
        }
        else
        {
            QMessageBox::warning(this,"warn","未拥有该战机");
        }

    });

    //僚机6
    Wing_Btn6=new QPushButton;
    Wing_Btn6->setParent(this);
    Wing_Btn6->setIcon(QIcon(":/rec.image/Wing07_nobuy.png"));
    Wing_Btn6->setIconSize(QSize(800,800));
    Wing_Btn6->setFixedSize(100,100);
    Wing_Btn6->move(450,500);
    Wing_Btn6->setFlat(true);
    Wing_Btn6->setAttribute(Qt::WA_TranslucentBackground);
    //选择僚机6
    connect(Wing_Btn6,&QPushButton::clicked,[=](){
        btn_music->play();
        if(Wing6_isbuy)
        {
            QMessageBox msgBox;
            msgBox.setInformativeText("   是否出战？  ");
            msgBox.setStandardButtons(QMessageBox::Yes |  QMessageBox::Cancel);
            //msgBox.setDefaultButton(QMessageBox::Save);
            QPixmap pix;
            pix.load(":/rec.image/Wing07.png");
            msgBox.setIconPixmap(pix);
            msgBox.setWindowTitle("选择战机");
            msgBox.setWindowIcon(QIcon(":/rec.image/Icon.png"));
            int ret = msgBox.exec();
            switch (ret) {
            case QMessageBox::Yes:

                emit(SelectWing6());
                break;

            }
        }
        else
        {
            QMessageBox::warning(this,"warn","未拥有该战机");
        }
    });


    //按钮音效
    btn_music=new QSound(MUSIC_BTN);
}

void ChooseHero::paintEvent(QPaintEvent *e)
{
    QPixmap pix;
    pix.load(":/rec.image/Choose_Back.jpg");
    QPainter painter(this);
    painter.drawPixmap(0,0,pix);





}
